using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;

public class AddItem : MonoBehaviour//添加物品
{
    public List<ItemSO> itemList;
    public Inventory inventory;
    
    public void OnClick()
    {
        bool isHave = false;
        int range = Random.Range(0, itemList.Count);
        InventoryUI.Instance.AddItem(itemList[range]);
        int num = inventory.itemList.Count;
        for (int i = 0; i < num; i++)
        {
            if (inventory.itemList[i].itemSO == itemList[range])
            {
                isHave = true;
                break;
            }
        }

        if (!isHave)
        {
            inventory.itemList.Add(new ItemInInv() { itemSO = itemList[range], isHad = true });
        }
    }
}
